﻿package com.tudou.home.controller
{
    import com.tudou.home.commands.*;
    import com.tudou.home.model.*;
    import com.tudou.home.view.*;
    import com.tudou.js.*;
    import com.tudou.track.*;
    import org.puremvc.as3.interfaces.*;
    import org.puremvc.as3.patterns.command.*;

    public class PageCommand extends SimpleCommand
    {

        public function PageCommand()
        {
            return;
        }// end function

        private function startCollectionData() : void
        {
            var judge:Function;
            var callback:Function;
            judge = function (param1:String) : Boolean
            {
                var _loc_2:Array = null;
                if (param1)
                {
                    _loc_2 = param1.split("|");
                    return _loc_2.length == 2 && _loc_2[0] && _loc_2[1];
                }
                return false;
            }// end function
            ;
            callback = function (param1:String) : void
            {
                AOPTracker.getInst().addNodeLog(NodeLog.PAGE_LOAD_TIME, [param1]);
                return;
            }// end function
            ;
            JSExchanger.getInst().getData("loadTime", callback, judge);
            return;
        }// end function

        override public function execute(param1:INotification) : void
        {
            var _loc_2:* = facade.retrieveProxy(PlayerProxy.NAME) as PlayerProxy;
            var _loc_3:* = facade.retrieveProxy(PageProxy.NAME) as PageProxy;
            var _loc_4:* = param1.getBody();
            var _loc_5:* = param1.getType();
            switch(param1.getName())
            {
                case PageCommandSet.PAGE_LOADED:
                {
                    _loc_3.startSavePlayedTime();
                    startCollectionData();
                    break;
                }
                case ViewCommandSet.ENTER_FULLSCREEN_AND_RESIZE:
                {
                    JSExchanger.getInst().notifyJS("fullscreen", [true]);
                    break;
                }
                case ViewCommandSet.NORMALSCREEN_RESIZE:
                {
                    break;
                }
                case ViewCommandSet.REAL_EXIT_FULLCREEN:
                {
                    JSExchanger.getInst().notifyJS("fullscreen", [false]);
                    break;
                }
                case ViewCommandSet.EXPAND_STAGE:
                {
                    if (_loc_5 == SkinMediator.NAME)
                    {
                        _loc_3.expand(_loc_4);
                    }
                    break;
                }
                case PageCommandSet.GET_LIVE_DATA:
                {
                    _loc_3.setLiveData(_loc_4 as XML);
                    break;
                }
                case PageCommandSet.LOAD_SHARE_RELATIVE_DATA:
                {
                    _loc_3.loadShareRelativeData();
                    facade.removeCommand(PageCommandSet.LOAD_SHARE_RELATIVE_DATA);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
